#include<iostream>
using namespace std;

class MyInteger
{
friend ostream &operator<< (ostream &cout, MyInteger myint);
	
public:
	MyInteger()
	{
	m_Num = 0;	
	}  
	  
//重载前置++运算符
MyInteger& operator++ ()
{
	//先+1 
	m_Num++;
	//后返回 
	//返回值使自身所以用this指针指向自身。 
	return *this;
}

//重载后置++运算符
MyInteger operator++(int )//int是占位参数以满足函数重载 ，可以用于区分前置和后置递增 
{
    //先返回 后递增
	//采用先记录自身的值后+1
	MyInteger temp = *this;
	m_Num++;
	return temp;//后置递增要返回一个值 
}
private:
    int m_Num;	
};

//<<运算符重载只能用全局函数重载。 
ostream& operator<< (ostream &cout, MyInteger myint)
{
	cout << myint.m_Num;
	return cout;
}

void test1 ()
{
	MyInteger myint;
	cout << ++myint << endl;
	cout << myint << endl;
}

void test2 ()
{
	MyInteger myint;
	cout << myint++ << endl;
	cout << myint << endl;
} 

int main ()
{
	//test1();
	test2();
	return 0;
} 